// 规范化分包根目录路径
export function normalizeSubpackageRootPath(rootPath) {
  // 掐头
  rootPath = rootPath.replace(/^\//, '');
  // 补全开头 pages
  if (!rootPath.match(/^pages/)) {
    rootPath = `pages/${rootPath}`;
  }
  // 接尾
  if (!rootPath.match(/\/$/)) {
    rootPath += '/';
  }
  return rootPath;
}
// 补全分包页面路径
export function joinSubpackagePagePath(pagePath, rootPath) {
  rootPath = normalizeSubpackageRootPath(rootPath);
  pagePath = `${rootPath}${pagePath}`;
  return pagePath.replace(/\/{2,}/, '/');
}
// 拆解分包页面路径
export function splitSubpackagePagePath(pagePath, rootPath) {
  rootPath = normalizeSubpackageRootPath(rootPath);
  return pagePath.replace(rootPath, '');
}
